package conf

import (
	"github.com/spf13/viper"
	"go.uber.org/zap"
)

// VarsSection map toml [vars]
type VarsSection struct {
	WebposURI       string `mapstructure:"webpos_uri"`
	AccountSecret   string `mapstructure:"account_secret"`
	HTTPTimeout     uint8  `mapstructure:"http_timeout"`
	GrpcTimeout     uint8  `mapstructure:"grpc_timeout"`
	MchIDAsService  string `mapstructure:"mch_id_as_service"`
	MchIDAsProfit   string `mapstructure:"mch_id_as_profit"`
	MchNameAsProfit string `mapstructure:"mch_name_as_profit"`
}

// ReadVars get vars section from config
func ReadVars(v *viper.Viper, slog *zap.SugaredLogger) (varsConf VarsSection) {
	err := v.Unmarshal(&varsConf)
	if err != nil {
		slog.Panicf("unable to decode into wxpay section, %v", err)
	}
	return
}
